/**
 *
 * @author ilya portnyagin iportnyagin@gmail.com
 */

package ru.portnyagin.helpdeskru.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "History_Request")
public class HistoryRequest implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
//    @Basic(optional = false)
//    @NotNull
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private Long id;
    
    @JoinColumn(name = "REQUEST", referencedColumnName = "ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Request request;
    
//    @Column(name = "MODIFIED_BY")
//    private String modifiedBy;
    

    @JoinColumn(name = "MODIFIED_BY", referencedColumnName = "ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private UserHD modifiedBy;
        
    
    @Column(name = "MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifiedDate;
    
    @Column(name = "PROPERTY_NAME")
    private String propertyName;

    @Column(name = "PROPERTY_VALUE")
    private String propertyValue;
    
    public HistoryRequest() {
    }

    public HistoryRequest(Request request, UserHD modifiedBy, Date modifiedDate, String propertyName, String propertyValue) {
        this.request = request;
        this.modifiedDate = modifiedDate;
        this.modifiedBy = modifiedBy;
        this.propertyName = propertyName;
        this.propertyValue = propertyValue;
    }

    public HistoryRequest(Long id) {
        this.id = id;
    }

    
    
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Request getRequest() {
        return request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }

    public UserHD getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(UserHD modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public String getPropertyValue() {
        return propertyValue;
    }

    public void setPropertyValue(String propertyValue) {
        this.propertyValue = propertyValue;
    }
 
    
    
    
    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof HistoryRequest)) {
            return false;
        }
        HistoryRequest other = (HistoryRequest) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "HistoryRequest[ id=" + id + " ]";
    }
    
    
    
    
    
    
    
}
